<!--TODO 暂时没有数据-->
<% include ../header.ejs %>
<link rel="stylesheet" href="/stylesheets/app/recommend/recommed.css">
<header data-am-widget="header" data-am-sticky class="am-header am-header-default" id="appTemplates-Nav">
    <div class="am-header-left am-header-nav">
        <a href='<%= (typeof(page) != 'undefined' && page=='search')?'javascript:history.go(-1);':'stockpoolindex'%>'>
            <img class="am-header-icon-custom" src="data:image/svg+xml;charset&#x3D;utf-8,&lt;svg xmlns&#x3D;&quot;http://www.w3.org/2000/svg&quot; viewBox&#x3D;&quot;0 0 12 20&quot;&gt;&lt;path d&#x3D;&quot;M10,0l2,2l-8,8l8,8l-2,2L0,10L10,0z&quot; fill&#x3D;&quot;%23fff&quot;/&gt;&lt;/svg&gt;" alt=""/>
        </a>
    </div>

    <h1 class="am-header-title">
        <a href="#title-link" class="" id="Typeface-whitecolor">股票详情</a>
    </h1>

    <div class="am-header-right am-header-nav">
        <% if(mConference.createUid == userinfo.rowId && typeof(page) == 'undefined'){%>
        <a href="#" class = "editBut">编辑</a>
        <%}%>
    </div>
</header>

<form class="am-form" style="margin: 2%">
    <div data-am-widget="titlebar" class="am-titlebar am-titlebar-default">
        <h2 class="am-titlebar-title"><%= mConference.stockId.name %></h2>
    </div>

    <%if(mConference.parentPoolId){%>
    <div class="am-list-item-hd am-g am-div-margin" style="margin-top: 1rem">
        <div class="am-u-sm-4">
            <p class="am-list-item-hd">一级股票池</p>
        </div>
        <div class="am-u-sm-8 am-fr">
            <p class="am-list-item-hd"><%= (mConference.parentPoolId.poolName) || '' %></p>
        </div>
    </div>
    <%}%>

    <%if(mConference.childPoolId){%>
    <div class="am-list-item-hd am-g am-div-margin" style="margin-top: 1rem">
        <div class="am-u-sm-4">
            <p class="am-list-item-hd">二级股票池</p>
        </div>
        <div class="am-u-sm-8 am-fr">
            <p class="am-list-item-hd"><%= (mConference.childPoolId.poolName) || '' %></p>
        </div>
    </div>
    <%}%>

    <div class="am-list-item-hd am-g am-div-margin" style="margin-top: 1rem">
        <div class="am-u-sm-4">
            <p class="am-list-item-hd">分析师</p>
        </div>
        <div class="am-u-sm-8 am-fr">
            <p class="am-list-item-hd"><%= (mConference.createUserId && mConference.createUserId.name) || '' %></p>
        </div>
    </div>

    <div class="am-list-item-hd am-g am-div-margin">
        <div class="am-u-sm-4">
            <p class="am-list-item-hd">调入日期</p>
        </div>
        <div class="am-u-sm-8 am-fr">
            <p class="am-list-item-hd"><%= mConference.updateTime %></p>
        </div>
    </div>

    <div class="am-list-item-hd am-g am-div-margin">
        <div class="am-u-sm-4">
            <p class="am-list-item-hd">调入价</p>
        </div>
        <div class="am-u-sm-8 am-fr">
            <p class="am-list-item-hd"><%= mConference.importPrice %></p>
        </div>
    </div>

    <div class="am-list-item-hd am-g am-div-margin">
        <div class="am-u-sm-4">
            <p class="am-list-item-hd">目标价</p>
        </div>
        <div class="am-u-sm-8 am-fr">
            <p class="am-list-item-hd"><%= mConference.expectPrice %></p>
        </div>
    </div>

    <div class="am-list-item-hd am-g am-div-margin">
        <div class="am-u-sm-4">
            <p class="am-list-item-hd">目标涨幅</p>
        </div>
        <div class="am-u-sm-8 am-fr">
            <p class="am-list-item-hd"><%= mConference.expectRate %></p>
        </div>
    </div>

    <div class="am-list-item-hd am-g am-div-margin">
        <div class="am-u-sm-4">
            <p class="am-list-item-hd">实际涨幅</p>
        </div>
        <div class="am-u-sm-8 am-fr">
            <p class="am-list-item-hd" id="realRate">
                <% if(mConference.stockId!=null){ %>
                <script type="text/javascript">
                    $(function () {
                        $.get("/smtool_project/wxapp/api/stock/getRealPrice?stockCode=<%= mConference.stockId.stockCode%>",function(repdata,status){
                            var importPrice = '<%= mConference.importPrice %>';
                            var realRate= getRealRate(importPrice,repdata)

                            $('#realRate').text(toDecimal(realRate))
                        });
                    });

                    function getRealRate(importPrice,realPrice)
                    {
                        return realPrice==""?realPrice:(realPrice-importPrice)*100/importPrice
                    }

                    function toDecimal(x) {
                        var f = parseFloat(x);
                        if (isNaN(f)) {
                            return "";
                        }
                        f = Math.round(x*100)/100;
                        return f+"%";
                    }
                </script>
                <%}%>
            </p>
        </div>
    </div>
    <% if(mConference.attachmentName && mConference.attachmentUrl){ %>
        <div class="am-list-item-hd am-g am-div-margin">
            <div class="am-u-sm-4">
                <p class="am-list-item-hd">附件</p>
            </div>
            <div class="am-u-sm-8 am-fr">
                <p class="am-list-item-hd"><a href="<%=mConference.attachmentUrl%>"><%= mConference.attachmentName %></a></p>
            </div>
        </div>
    <% } %>

    <div class="am-form-group">
        <textarea class="" rows="5" id="doc-ta-1" readonly><%= mConference.reason %></textarea>
    </div>

    <% if(mConference.isRecommend!=1){ %>
        <div id="divAction">
            <% if(mConference.createUid == userinfo.rowId && typeof(page) == 'undefined'){%>
            <button class="am-btn am-btn-danger" type="button" id="doc-delete-toggle">调出</button>
            <%}%>
            <!--<button class="am-btn am-btn-secondary" type="button" id="doc-save-toggle">保存</button>-->
        </div>
    <% } %>
</form>

<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-bd" id ="alert-msg">
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn">确定</span>
        </div>
    </div>
</div>
<!--详情删除-->
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-bd" id = "my-confirm-text">
            是否确定调出
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>
<!--评论删除-->
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-comment-confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-bd" id="my-confirm-text">
            是否确定删除
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>
<!--评论按钮-->
<div class="amz-toolbar" id="amz-toolbar" style="right: 27.5px;">
    <a href="##" class="am-icon-btn am-secondary am-icon-commenting-o" id="doc-prompt-toggle" onClick = "openComment('<%=mConference.rowId%>','/smtool_project/wxapp/morningconference/addComment','<%=userinfo.extension%>','stockpool')"></a>
</div>
<!--评论输入-->
<div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt">
    <div class="am-modal-dialog" style="width:90%;height: 22rem;">
        <div class="am-modal-hd">发表点评</div>
        <div class="am-modal-bd" style="width:100%;height: 12rem;">
            <textarea name="a" style="width:100%;height: 100%;" class="am-modal-prompt-input"></textarea>
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>发表</span>
        </div>
    </div>
</div>
<%commentList = commentList || [];
  if(commentList.length>0){%>
     <hr data-am-widget="divider" style="" class="am-divider am-divider-dashed" />
 <%}%>
<!--评论信息-->
<section data-am-widget="accordion" style="margin-left:0;margin-right: 0;" class="am-accordion am-accordion-gapped" data-am-accordion='{  }'>
    <dl class="am-accordion-item"><!-- am-active -->
        <dt class="am-accordion-title">
            点评列表
        </dt>
        <dd class="am-accordion-bd am-collapse">
            <div class="am-accordion-content"  style="height:47rem;width:100%;overflow-y: scroll;">
                <!-- comment list start -->
                <div data-tab-panel-1 class="am-panel-default">
                    <div>
                        <ul class="am-comments-list am-comments-list-flip">
                            <%commentList.forEach(function(data, key){ %>
                            <li class="am-comment" id="<%=data.rowId%>">
                                <article class="am-comment">
                                    <a href="#link-to-user-home">
                                        <img src="<%=data.createUid.extension%>" alt="" class="am-comment-avatar" width="48" height="48"/>
                                    </a>

                                    <div class="am-comment-main">
                                        <header class="am-comment-hd">
                                            <div class="am-comment-meta">
                                                <a href="#link-to-user" class="am-comment-author"><%=data.name%></a>
                                                点评于 <time datetime="" title=""><%=dateFormat(data.createdAt);%></time>
                                            </div>
                                            <div class="am-comment-actions" style="font-size:18px">
                                                <!--<a href="#" onClick = "editComment('<%=data.rowId%>')" class="am-margin-horizontal-sm">-->
                                                <!--<i class="am-icon-pencil"></i>-->
                                                <!--</a>-->
                                                <% if(userinfo.rowId == (data.createUid && data.createUid.rowId)){ %>
                                                    <a href="#" onClick = "delComment('<%=data.rowId%>')"><i class="am-icon-close"></i></a></div>
                                                <%}%>
                                        </header>

                                        <div class="am-comment-bd">
                                            <%=data.context%>
                                        </div>
                                    </div>
                                </article>
                            </li>
                            <%})%>
                        </ul>
                    </div>
                </div>
                <!-- comment list end -->
            </div>
        </dd>
    </dl>
</section>
<!--评论信息结束-->

<% include ../footer.ejs %>
<script src="/javascripts/app/comment/comment.js"></script>
<script>
    //删除功能
    $(function() {
        $(".editBut").on('click',function(){
            if(<%=userinfo.rowId == mConference.createUid%>){
                location.href = "edit?rowId=<%= mConference.rowId%>";
            }else{
                $('#alert-msg').html("您无权修改此数据");
                $('#my-alert').modal('open');
            }
        });
        $('#doc-delete-toggle').on('click', function() {
            $("#my-confirm-text").html("是否确定调出");
            $('#my-confirm').modal({
                relatedTarget: this,
                onConfirm: function(options) {
                    var options = {
                        url: 'stockpooldelete',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            'rowId': '<%= mConference.rowId%>'
                        },
                        error: function (request) {
                            $('#alert-msg').html("调出失败")
                            $('#my-alert').modal('open')
                        },
                        success: function (data) {
                            if(data.code==200){
                                location.href = "../stockpool/stockpoolindex"
                            }else{
                                $('#alert-msg').html("调出失败")
                                $('#my-alert').modal('open')
                            }
                        }
                    };
                    $.ajax(options);
                },
                onCancel: function() {
                }
            });
        });

    });


</script>
